<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
  <head>
    <title>显示所有人信息</title>
    <style>
    	header{ text-align:center; }
    	.content{ margin:10px auto; width:1200px; height:600px; }
    	.content table{ border:1px solid black; margin:10px auto; border-collapse:collapse;  }
    	.content table td,.content table th{ border:1px solid black; padding:4px; }
    </style>
  </head>
  
  <body>
  	<header><h3>显示所有人信息</h3></header>
  	<div class="content">
  		<table>
  			<tr><th>id</th><th>用户名</th><th>性别</th><th>年龄</th><th>手机号</th><th>QQ</th><th>email</th><th>操作</th><th>操作</th></tr>
  			<!-- 循环所有人的信息 -->
  			<%-- 获取request域中数据 --%>
  			<c:forEach items="${requestScope.contactsList }" var="contacts">
	  			<tr>
		  			<td>${contacts.id }</td>
		  			<td>${contacts.name }</td>
		  			<td>${contacts.gender }</td>
		  			<td>${contacts.age }</td>
		  			<td>${contacts.QQ }</td>
		  			<td>${contacts.telephone }</td>
		  			<td>${contacts.email }</td>
		  			<td><a href="${pageContext.request.contextPath }/QueryContactsServlet?id=${contacts.id }">修改</a></td>
		  			<td><a href="${pageContext.request.contextPath }/DeleteServlet?id=${contacts.id }">删除</a></td>
	  			</tr>
  			</c:forEach>
  			<tr>
  				<td colspan="9" style="text-align:center;"><a href="${pageContext.request.contextPath }/addContacts.jsp">添加联系人</a></td>
  			</tr>
  			<c:choose>
  				<c:when test="${requestScope.addResult }">
  					<tr><td colspan="9" style="text-align:center; color:red; font-weight:bold;">添加联系人成功！</td></tr>
  				</c:when>
  				<c:when test="${requestScope.addResult==false }">
  					<tr><td colspan="9" style="text-align:center; color:red; font-weight:bold;">用户的id或姓名重复！</td></tr>
  				</c:when>
  				<c:when test="${requestScope.modifyResult }">
  					<tr><td colspan="9" style="text-align:center; color:red; font-weight:bold;">修改联系人成功！</td></tr>
  				</c:when>
  				<c:when test="${requestScope.delResult }">
  					<tr><td colspan="9" style="text-align:center; color:red; font-weight:bold;">删除联系人成功！</td></tr>
  				</c:when>
  			</c:choose>
  		</table>
  		
  	</div>
  </body>
</html>
